package com.example.ovulationperiodtracker.Allactivity;

import android.os.Bundle;
import android.view.LayoutInflater;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.example.ovulationperiodtracker.adapter.MedicineAdapter;
import com.example.ovulationperiodtracker.adapter.NotificationDAdapter;
import com.example.ovulationperiodtracker.databinding.ActivityNotificationDBinding;
import com.example.ovulationperiodtracker.view.NavigationView;
import com.example.ovulationperiodtracker.view.NoteUtils;
import com.necer.base.BaseActivity;
import com.tencent.mmkv.MMKV;

import java.util.Objects;

public class NotificationDActivity extends BaseActivity<ActivityNotificationDBinding> {

    private static final MMKV mmkv = MMKV.defaultMMKV();

    @Override
    protected ActivityNotificationDBinding createBinding(LayoutInflater inflater) {
        return ActivityNotificationDBinding.inflate(inflater);
    }

    @Override
    protected void onCreated(Bundle savedInstanceState) {


        String position = getIntent().getStringExtra("position");
        if (Objects.equals(position, "0")) {
            binding.navigation.setTitle("经期提醒");
        } else if (Objects.equals(position, "1")) {
            binding.navigation.setTitle("易孕期期提醒");
        } else if (Objects.equals(position, "2")) {
            binding.navigation.setTitle("排卵提醒");
        }

        String notifications = mmkv.decodeString("Notification" + position, "");

        NotificationDAdapter adapter = new NotificationDAdapter(context, binding.recyclerView);
        adapter.setChecked(notifications);
        binding.recyclerView.setLayoutManager(new LinearLayoutManager(context));
        binding.recyclerView.setAdapter(adapter);

        binding.navigation.setOnClickRightListener(new NavigationView.OnClickRightListener() {
            @Override
            public void onClickRight() {
                String texts = adapter.getChecked();
                mmkv.encode("Notification" + position, texts);
                finish();
            }
        });
    }
}
